#include <bits/stdc++.h>
using namespace std;
int t;

vector<int> div(vector<int> &A, int B) {
	vector<int> C;
	for (int i = A.size() - 1; i >= 0; --i) {
		t = t * 10 + A[i];
		C.push_back(t / B);
		t %= B;
	}
	reverse(C.begin(), C.end());
	while (C.size() > 1 && C.back() == 0) {
		C.pop_back();
	}
	return C;
}

int main() {
	string a;
	int B;
	vector<int> A, C;
	cin >> a >> B;
	for (int i = a.size() - 1; i >= 0; --i) {
		A.push_back(a[i] - '0');
	}
	C = div(A, B);
	for (int i = C.size() - 1; i >= 0; --i) {
		cout << C[i];
	}
	cout << endl << t;
	return 0;
}